package com.nubia.service;

import com.nubia.dao.CartDao;
import com.nubia.entity.Cart;
import com.nubia.entity.PersonShops;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class CartServiceImpl implements CartService {
    @Autowired
    CartDao cartDao;

    /**
     * 根据id添加购物车
     * @param cart
     * @return
     */
    @Override
    public int addCartByBothId(Cart cart) {
        return cartDao.insertByBothId(cart);
    }

    @Override
    public Cart findCartByBothId(Cart cart) {
        return cartDao.selectByBothId(cart);
    }

    @Override
    public List<PersonShops> findUserCartListById(Cart cart) {
        return cartDao.selectUserCartListById(cart);
    }

    @Override
    public int delCartById(String cart_id) {
        return cartDao.deleteCartById(cart_id);
    }

}
